<style>
.item_s{height:30px;line-height:30px;}
</style>

   	<link rel="StyleSheet" href="/static/AuthorityTree/dtree.css" type="text/css" />
	<script type="text/javascript" src="/static/AuthorityTree/dtree.js?t=1"></script>
   
   
   <section class="topBanners">
         <div class="icon"></div>
         <div class="topBannersNav">
         <span data-url="/admin/group/lists"  onclick="ContentLoadGo('/admin/group/lists')">角色管理</span> >
         <span data-url="/admin/group/power2" data-param-id="<?php echo $info['id'] ?>" data-container="rt_content" class="topBannerItem">权限管理</span>
         </div>
      </section>
     
 
   <section id="zc_detail">

      
     
      <div style="height:50px;line-height:50px;text-align:center;font-size:20px;font-weight:800"><?php echo $info['gname']; ?></div>
      

     
        <div id="mystree" style="width:90%;text-align:left;font-size:16px;margin:10px auto;">
        </div>
   
      
      <ul class="ulColumn2">
      
      
       <li style="text-align:center">
        <input type="hidden" name="depthID" id="depthID" value="<?php echo $info['id'] ?>">
        <input type="button" value="设置" class="link_btn set_power"/>
        
       </li>
      </ul>
     </section>
      <script type="text/javascript">
      function myResearch(){
		   var url="/admin/group/power2";
		   var id =$("#depthID").val();
		   var param={
				  id:id
		   };
		   ContentGet(url,param);
	   }
           $(function(){
        	   //设置搜索栏
        	   $(".research").click(function(){
        		   myResearch();
        	   });
        	   //
        	   $('.set_power').click(function(){
        		   var that =this;
        		   var url="/admin/group/set_power";
        		   var id=$("#depthID").val();
        		   var power=getAllSelectItemPower1();
        		   
        		   var param={
        				   id:id,
        				   power:power
        		   };
        		   cofirmsss_tishi(1,'您确定要执行该操作吗？',function(id){
        			 
        			   AjaxRequest(url,param,function(data){
            			   if(data.err==0)
            			   {
            				   SuccessTiShi("操作成功");
            				   myResearch();
            			   }
            			   else
            			   {
            				   ErrTiShi("操作失败");
            			   }
            		   });
        			   
        		   });
        	   });

        	   //导航
        	   $(".topBannerItem").click(function(){
        		   var attArr = $(this).attr();
            	   goToSelfLink(attArr);
        	   });
  			   //全选
  				$(".powerItem").click(function(){  
  					var data=$(this).attr("mydata");
  					dataArr=data.split("_");
			    	if(this.checked){   
			    		var cs="";
			    		for(var i=0;i<dataArr.length;i++)
			    			{
			    			   if(cs=="")
			    			   {
			    				   cs=dataArr[i];
			    			   }else
			    			   {
			    				   cs=cs+"_"+dataArr[i];
			    			   }

			    			   $("#"+cs).attr("checked", true);
			    			   $("#"+cs).prop("checked", true);
			    			   
			    			}
			        	}else{
			    		$('input[id*='+data+']').attr("checked", false);
			    		$('input[id*='+data+']').prop("checked", false);
			    		}
			    	var se=getAllSelectItem();
			 	}); 
  				
  				setTimeout(function(){
  					showTree();
  				}, 100 );
  			
           });
           function showTree()
           {
        	d = new dTree('d');
       		d.add(0,-1,'菜单权限项');
       		
       		<?php
       		foreach($ruleobjLists as $key=>$val)
       		{   
       			if(!empty($val['ischeck']))
       				{
       		?>
       				d.add(<?php echo $val['id'] ?>,<?php echo $val['father'];?>,'authority',"<?php echo $val['id'] ?>","<?php echo $val['oname']; ?>",true);
       		<?php
       				}else
       				{
       		?>
       			d.add(<?php echo $val['id'] ?>,<?php echo $val['father'];?>,'authority',"<?php echo $val['id'] ?>","<?php echo $val['oname']; ?>");
       		<?php
       				}
       		}
       		?>

			$("#mystree").html("<div></div>"+d);
		    d.openAll();
           }
           
           function getAllSelectItemPower1(){
        	   var str="";
        		var count = 0;
        		var obj = document.all.authority;	
        		
        		for(i=0;i<obj.length;i++){
        			if(obj[i].checked){					
        			
        				if(str=="")
         	    		  {
         	    		str+=obj[i].value;
         	    		  }
         	    	    else
         	    		  {
         	    		str+=","+obj[i].value;
         	    		  }
         	    	  		
        				count ++;				
        			}
        		}	
        		return str;
        	}
           
           function getAllSelectItemPower()
           {
           	      var str="";
           	      $("input[name='powerItem[]']:checked").each(function(){
           	    	  if(str=="")
           	    		  {
           	    		str+=$(this).val();
           	    		  }
           	    	  else
           	    		  {
           	    		str+=","+$(this).val();
           	    		  }
           	    	  		
           	    	  });
           	      return str;
           }
           
	  </script>
	  
	  
   